package com.hsp.Demo_05_extends;

public class Demo_04 {
    public static void main(String[] args) {
        /*
        Java动态绑定
         */
        AA_04 aa = new BB_04();
        System.out.println(aa.sum()); //30
        System.out.println(aa.sum1()); //40
    }
}

class AA_04{
    int count = 10;

    public int sum(){
        return getCount() + 10;
    }

    public int getCount(){
        return count;
    }

    public int sum1(){
        return getCount() + 20;
    }
}

class BB_04 extends AA_04{
    int count = 20;

//    public int sum(){
//        return count + 10;
//    }

    public int getCount(){
        return count;
    }

    public int sum1(){
        return count + 20;
    }
}
